#ifndef MYFUNCTIONS_H_
#define MYFUNCTIONS_H_

#include <stdio.h>
#include <stdlib.h> 
#include <sys/types.h>
#include <dirent.h>
#include <cstdarg>
#include <cstddef>
#include <cstdlib>
#include <cstring>
#include <string>
#include <sstream>
#include <iostream>
#include <vector>
#include <stack>
#include <fstream>
#include <algorithm>
#include <time.h>
#include <malloc.h>
#include <string.h>

#include <oslib/oslib.h>

#include <pspiofilemgr.h>
#include <psppower.h>
#include <pspctrl.h>
#include <pspdisplay.h>
#include <psputils.h>
#include <psprtc.h>
#include <pspthreadman.h>
#include <pspsdk.h>
#include <pspuser.h>

#include <pspaudio.h>
#include <pspaudiolib.h>

#include <pspumd.h>

using namespace std;

#include "Libs/ArrayList.h"
#include "objectdraw/objectdraw.h"

extern bool kja_suspend;
extern bool kja_resume;

struct DirObj
{
	string name;
	string absoluteLocation;
	string ext;
	
	ScePspDateTime atime;
	ScePspDateTime ctime;
	ScePspDateTime mtime;
	unsigned int attr;
	SceOff size;
	bool isDir;
	
};
struct setting
{
	string name;
	string value;
};

struct Date
{
	string hour;
	string min;
	string mon;
	string sec;
	string year;
	string mday;
	char * AMPM;
};

void loaderInit();
int loaderEnd();
int loadOSLINITAUDIOMETHREAD(SceSize args, void *argp);
int SetupCallbacks(void);
int CallbackThread(SceSize args, void *argp);
int exit_callback(int arg1, int arg2, void *common);
int power_callback(int unknown, int pwrflags, void *common);

bool fileExist(string src);
bool dirExist(string src);

vector<string> getFileData(const char *_fileloc);
vector<string> getFileDataB(const char *_fileloc);
vector<DirObj> getDirData(const char *_dirloc);

void saveFileData(const char *_fileloc,vector<string> _data);

typedef void (*MFTHREAD)();
int addFunc(MFTHREAD _thread);
void runMF_MAIN_THREAD();

SceUID createThread(SceKernelThreadEntry tfunc,char *tname);

Date getDate();
void Pause(int _delay);
int keylistCmp(OSL_KEYLIST k1, OSL_KEYLIST k2);

SceUID load_module(const char *path, int flags, int type);

void osl_onload_fail_callback(const char *filename,u32 reserved);
int umd_callback(int arg1, int arg2, void *arg);
bool umd_in(); 

#endif /*MYFUNCTIONS_H_*/
